import request from "./request";
// 用户登录
export const adminLogin = (
  params: IAdminLoginParams
): IResponseData<ILoginData> => request.post("/admin/login", params);
// 获取用户信息
export const adminInfo = (): IResponseData<IInfoData> =>
  request.get("/admin/info");
// 获取侧边栏列表
export const adminList = (
  params: IUserListParams
): IResponseData<IUserListData> => request.get("/admin/list", { params });
// 改变用户状态
type IStatus = {
  id: number;
  status: 0 | 1;
};
export const adminUpdateStatus = (
  id: number,
  status: 0 | 1
): IResponseData<0 | 1> =>
  request.post(`/admin/updateStatus/${id}`, {}, { params: { status } });

// 获取用户权限
export const adminRole = (id: number): IResponseData<IUserRole[]> =>
  request.get(`/admin/role/${id}`);
// 改变用户权限
export const adminRoleUpdate = (params: FormData): IResponseData<number> =>
  request.post(`/admin/role/update`, params);
// 改变用户信息
export const adminUpdate = (
  id: number,
  params: IUserListDataItem
): IResponseData<number> => request.post(`/admin/update/${id}`, params);
// 用户注册
export const adminRegister = (
  params: IAddUserInfo
): IResponseData<IUserListDataItem> => request.post(`/admin/register`, params);
// 用户注册
export const adminDelete = (id: number): IResponseData<any> =>
  request.post(`/admin/delete/${id}`);
// 退出接口
export const adminLogout = (): IResponseData<any> =>
  request.post(`/admin/logout`);
// 获取所有角色
export const roleListAll = (): IResponseData<IRoleListItem[]> =>
  request.get(`/role/listAll`);
// 按需获取角色列表, 参数和获取用户数据格式相同, 共用一个
export const roleList = (
  params: IUserListParams
): IResponseData<IRoleListData> => request.get("/role/list", { params });

// 改变角色状态
export const roleUpdateStatus = (
  id: number,
  status: 0 | 1
): IResponseData<0 | 1> =>
  request.post(`/role/updateStatus/${id}`, {}, { params: { status } });

<<<<<<< HEAD
//查询后台所有资源
export const resourceListAll = (): IResponseData<IRoleListResourceItem> =>
  request.get("/resource/listAll");
// 查询后台所有资源分类
export const resourceCategoryListAll = (): IResponseData<IRoleListResource> =>
  request.get("/resourceCategory/listAll");
// 获取相应角色不同资源
export const roleListResource = (
  id: string
): IResponseData<IRoleListResourceItem> =>
  request.get(`/role/listResource/${id}`);
export const roleAllocResource = (params: FormData): IResponseData<number> =>
  request.post(`/role/allocResource`, params);
=======
>>>>>>> 261983f648213460fbec4ccce8308acf55f3924a
